import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import AppMain from '@/views/main'
import System from './modules/system'
import Tax from './modules/tax'
import Funds from './modules/funds'
import Freeze from './modules/freeze'
import Law from './modules/law'
import Hr from './modules/hr'
import Report from './modules/report'


export const constantRoutes = [
    // 动态路径参数 以冒号开头
    {
      path: '/login',
      component: () => import('@/views/login/index'),
      hidden: true
    },
    {
      path: '/',
      component: AppMain,
      hidden: true,
      children: [
        Tax,
        Funds,
        Freeze,
        Law,
        Hr,
        Report,
        System
      ]
    },
    {
      path: '/404',
      component: () => import('@/views/error-page/404'),
      //hidden: true
    },
    { 
      path: '*',
      redirect: '/404', 
      hidden: true 
    }
]

const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })
  
  const router = createRouter()
  
  // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
  }
  
  export default router